﻿CREATE FUNCTION [QIC].[CallFactory_] (@DelegateName varchar(50), @Token [QIC].[TokenTable] READONLY, @CallerId int, @CalleeId int, @ReturnPropertName varchar(50), @TokenMap varchar(50), @Indent int, @CalleeDelegateName varchar(50))
RETURNS varchar(MAX)
AS
BEGIN

	IF @DelegateName='FN'
	BEGIN
		RETURN [QIC].[CallFactory_FN] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='IF'
	BEGIN
		RETURN [QIC].[CallFactory_IF] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='P'
	BEGIN
		RETURN [QIC].[CallFactory_P] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='TF'
	BEGIN
		RETURN [QIC].[CallFactory_TF] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='V'
	BEGIN
		RETURN [QIC].[CallFactory_V] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='VINSERT'
	BEGIN
		RETURN [QIC].[CallFactory_VINSERT] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='VUPDATE'
	BEGIN
		RETURN [QIC].[CallFactory_VUPDATE] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END
	IF @DelegateName='VDELETE'
	BEGIN
		RETURN [QIC].[CallFactory_VDELETE] (@Token, @CallerId, @CalleeId, @ReturnPropertName, @TokenMap, @Indent, @CalleeDelegateName)
	END

	--DEFAULT
	RETURN NULL

END

